<?php

$db = Zend_Db_Table_Abstract::getDefaultAdapter();

$status = '';
$turma = '';
    
if($this->data['ALU_ID'] > 0){
    
    $query = 'SELECT SQL_CACHE m.MAT_ID, m.MAT_STA, m.CUR_ID '
            . 'FROM MATRICULA m, CURSO c  '
            . 'WHERE m.CUR_ID = c.CUR_ID AND MAT_STA = 1 AND CUR_STA = 1 AND m.ALU_ID = ' . $this->data['ALU_ID'];
    $r_mat = $db->fetchRow($query);
    
    $status = strtoupper(aluno::returnStatusAluno($this->data['ALU_ID']));
    
    if(isset($r_mat['MAT_STA']) && $r_mat['MAT_STA'] == 0){
        $query = 'SELECT SQL_CACHE FIL_ID FROM FILA_MATRICULA WHERE MAT_ID = '.$r_mat['MAT_ID'];
        $r_fila = $db->fetchRow($query);
        if(isset($r_fila['FIL_ID']) && $r_fila['FIL_ID'] > 0) $status =  '<span class="aln_fila">FILA DE ESPERA</span>';
    }
    
    if($r_mat['CUR_ID'] > 0) $turma = dominio::getTurma($r_mat['CUR_ID']);
    
}

function sel_menu($action,$op){
    if($action == $op) echo 'class="sel"';
}

$img = ''; 
$imgs = 'public/upload/aluno/'.$this->data['ALU_ID'].'_det.*';
foreach (glob($imgs) as $src) {
    $img = $src;
}
?>

    <div class="content-laterial">
        <div class="content-img">
            <img src="<?php echo '/'.$img; ?>" />  
            <?php if($this->data['ALU_ID'] > 0){ ?>
            <div class="cnt-btna">
                <a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'foto', 'id' => $this->data['ALU_ID'])); ?>" class="btn-pdr">Cadastrar Foto</a>
            </div>
            <?php } ?>
        </div>
        <ul class="menu">
            <li <?php sel_menu($this->action,'edit'); ?>><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $this->data['ALU_ID'])); ?>">Dados</a></li>
            <?php if($this->data['ALU_ID'] > 0){ ?>
            <li <?php sel_menu($this->action,'galeria'); ?>><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'galeria', 'id' => $this->data['ALU_ID'])); ?>">Galeria de Fotos</a></li>
            <li <?php sel_menu($this->action,'opcaovestibular'); ?>><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'opcaovestibular', 'id' => $this->data['ALU_ID'])); ?>">Opção de Vestibular</a></li>
            <li <?php sel_menu($this->action,'boletimredacao'); ?>><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'boletimredacao', 'id' => $this->data['ALU_ID'])); ?>">Boletim de Desempenho</a></li>
            <li <?php sel_menu($this->action,'matricula'); ?>><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'matricula', 'id' => $this->data['ALU_ID'])); ?>">Histórico de Matriculas</a></li>
            <li <?php sel_menu($this->action,'material'); ?>><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'material', 'id' => $this->data['ALU_ID'])); ?>">Materiais</a></li>
            <li <?php sel_menu($this->action,'senha'); ?>><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'senha', 'id' => $this->data['ALU_ID'])); ?>">Usuário e Senha</a></li>
            <?php /*
            <li><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $this->data['ALU_ID'])); ?>">Boletim de Desempenho</a></li>
            <li><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $this->data['ALU_ID'])); ?>">Aprovação</a></li>
            <li><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $this->data['ALU_ID'])); ?>">Questionário</a></li>
            <li><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $this->data['ALU_ID'])); ?>">Pagamentos</a></li>
            <li><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $this->data['ALU_ID'])); ?>">Contrato</a></li>
            <li><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $this->data['ALU_ID'])); ?>">Carteira de Estudante</a></li>
            */ ?>
            <?php } ?>
        </ul>
    </div>
    <?php if($this->data['ALU_ID'] > 0){ ?>
    <div class="row">
        <strong>Status:</strong> <?php echo $status; ?>
        <span class="separador"></span>
        <strong>Turma:</strong> <?php echo $turma; ?> 
        <span class="separador"></span>
        <strong>Pagamento:</strong>
    </div>
    <div class="row tl_aln">
        <?php echo $this->data['ALU_NOM']; ?>
    </div>
    <?php } ?>